Page({
  data: {
    html: '<p class="xing-p">请在此输入内容</p>',
		_authval:'',
		header:{
			'cookie': '',
			"Content-Type": "application/x-www-form-urlencoded"
		},
		upFormData:{
			flag:8
		},
		type:''
  },
	onLoad(options){
		const { type } = options
		console.log(type);
		
		/* 
		companyProduct:'',//企业简介
		companyDemand:'',//产品
		companyRecruit:'',//需求
		companyProfile:'',//招聘 
		*/
		let html='',_type='';
		if(type == 'companyProduct'){
			const companyProduct = wx.getStorageSync('companyProduct')
			_type = 'companyProduct'
			if(companyProduct){
				html = companyProduct
			}
		}else if(type == 'companyDemand'){
			console.log(type);
			const companyDemand = wx.getStorageSync('companyDemand')
			_type = 'companyDemand'
			if(companyDemand){
				html = companyDemand
			}
		}else if(type == 'companyRecruit'){
			const companyRecruit = wx.getStorageSync('companyRecruit')
			_type = 'companyRecruit'
			if(companyRecruit){
				html = companyRecruit
			}
		}else if(type == 'companyProfile'){
			const companyProfile = wx.getStorageSync('companyProfile')
			_type = 'companyProfile'
			if(companyProfile){
				html = companyProfile
			}
		}
		
		this.setData({
			type:_type,
			html:html
		})
		
		const _authval = wx.getStorageSync('_auth')
		if(_authval){
			this.setData({
				['header.cookie']:"_auth=" + _authval
			})
		}
	},

  finish: function (e) {
			const content = e.detail.content
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2]
			
			if(this.data.type == 'companyProduct'){
				wx.setStorageSync('companyProduct',content)
				prevPage.setData({
					['formData.companyProduct']: content,
				})
			}else if(this.data.type == 'companyDemand'){
				wx.setStorageSync('companyDemand',content)
				prevPage.setData({
					['formData.companyDemand']: content,
				})
			}else if(this.data.type == 'companyRecruit'){
				wx.setStorageSync('companyRecruit',content)
				prevPage.setData({
					['formData.companyRecruit']: content,
				})
			}else if(this.data.type == 'companyProfile'){
				wx.setStorageSync('companyProfile',content)
				prevPage.setData({
					['formData.companyProfile']: content,
				})
			}
			
			wx.navigateBack()
  },
})
